﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CToolsWin.Files
{
    public partial class FileMD5Encrypt : Form
    {
        public FileMD5Encrypt()
        {
            InitializeComponent();
        }

        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.FileName = txtFileName.Text;
            fileDialog.ShowDialog();
            txtFileName.Text = fileDialog.FileName;
        }

        private void btnMD5Encrypt_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFileName.Text) == false)
            {
                System.IO.FileInfo file = new System.IO.FileInfo(txtFileName.Text);
                if (file != null)
                {
                    txtMD5Value.Text = Common.Tools.Encrypt.MD5.EncryptSimple(file.OpenRead());
                    txtFileProperty.Text = "";
                    txtFileProperty.Text +="文 件 名："+ file.Name;
                    txtFileProperty.Text += "\r\n\r\n扩 展 名：" + file.Extension;
                    txtFileProperty.Text += "\r\n\r\n所在目录：" + file.DirectoryName;
                    txtFileProperty.Text += "\r\n\r\n文件大小：" + file.Length;
                    txtFileProperty.Text += "\r\n\r\n创建时间：" + file.CreationTime;
                    txtFileProperty.Text += "\r\n\r\n修改时间：" + file.LastWriteTime;
                }
            }
        }
    }
}
